# Maintainer: Jordan Christiansen <xordspar0@gmail.com>
pkgname=lua-language-server
pkgver=3.8.3
pkgrel=0
pkgdesc="Language Server for Lua"
url="https://github.com/LuaLS/lua-language-server"
# s390x/ppc64le: ftbfs
arch="all !s390x !ppc64le"
license="MIT"
makedepends="bash linux-headers samurai"
subpackages="$pkgname-doc"
source="https://github.com/LuaLS/lua-language-server/archive/refs/tags/$pkgver/lua-language-server-$pkgver.tar.gz
	lua-language-server-submodules-$pkgver.zip.noauto::https://github.com/LuaLS/lua-language-server/releases/download/$pkgver/lua-language-server-$pkgver-submodules.zip
	wrapper
	"

prepare() {
	unzip -o "$srcdir"/lua-language-server-submodules-$pkgver.zip.noauto \
		-d "$builddir"
	default_prepare
}

build() {
	ninja -C 3rd/luamake -f compile/ninja/linux.ninja
	./3rd/luamake/luamake all
}

check() {
	./3rd/luamake/luamake unit-test
}

package() {
	install -Dm755 "$srcdir"/wrapper "$pkgdir"/usr/bin/lua-language-server
	install -Dm755 bin/lua-language-server \
		-t "$pkgdir"/usr/lib/lua-language-server/bin
	install -Dm644 bin/main.lua \
		-t "$pkgdir"/usr/lib/lua-language-server/bin
	install -Dm644 debugger.lua main.lua \
		-t "$pkgdir"/usr/lib/lua-language-server
	cp -a locale meta script "$pkgdir"/usr/lib/lua-language-server

	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

sha512sums="
d9335aef8fe36e6369aa32f042d521ea9234e2c1354e4731aa58003f9c81b3392b8315cd35a69ec980224647cc74e26216ab399a1a3a079d96a5351868a75492  lua-language-server-3.8.3.tar.gz
3f2bc7369c66f71556a45004d30b0d9926bf2b6ef692068dcbd347393b9e6599a503ee5fde9682fce870c556b88c1af3a5c9e0cd10b2c8f80341b0b3368a048d  lua-language-server-submodules-3.8.3.zip.noauto
d8d34d2ae8073c256b5f98f4cc7db058fbb92d63a5709894fca898ab47fcfcfca2d1419a1060c29464fbad937e3d09f0cde404b4d98609eec934ea4392044849  wrapper
"
